#!/bin/bash

# Start command: bash deploy.sh

# Check if the virtual environment exists
if [ -d "venv" ]; then
    echo "Virtual environment 'venv' exists"
else
    echo "Virtual environment 'venv' does not exist. Creating..."
    python -m venv venv
    echo "Virtual environment 'venv' created"
fi

# Activate the virtual environment
source venv/bin/activate
echo "Virtual environment 'venv' activated"

# Install the requirements
# Execute `pip install wheel` and capture the output
output=$(pip install wheel 2>&1)

# Print the output
echo "$output"

# Check if the output contains a warning about pip version
if echo "$output" | grep -q "WARNING: You are using pip version"; then
    echo "Found pip version warning. Upgrading pip..."
    pip install --upgrade pip
else
    echo "No pip version warning found"
fi

pip install loguru
pip install bce-python-sdk
pip install diskcache

# Execute custom deploy python script
python custom_deploy.py